package com.i8office.android.zhihuixinwu.module.model;

import com.cyan.tools.callback.RequestCallback;
import com.i8office.android.zhihuixinwu.app.App;
import com.i8office.android.zhihuixinwu.bean.NewsAttachment;
import com.i8office.android.zhihuixinwu.bean.Result;
import com.i8office.android.zhihuixinwu.module.contract.AttachmentContract;
import com.i8office.android.zhihuixinwu.util.OfficeSubscriber;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;

/**
 * Created by pc on 2018/7/8.
 */

public class AttachmentModel implements AttachmentContract.Model {

    @Override
    public Disposable getAttachments(RequestCallback<List<NewsAttachment>> callback, String id) {
        Map<String,String>  params = new HashMap<>();
        params.put("infoId",id);
        return  App.getComponent().getNewsService().getAttachments(params)
                .subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribeWith(new OfficeSubscriber<Result<List<NewsAttachment>>>(callback));
    }
}
